<template>
  <div id="wrapper">
    <nav-bar></nav-bar>
    <router-view v-on:deleteTime="deleteTime" v-on:timeUpdate="timeUpdate"></router-view>
  </div>
</template>

<script>
  import NavBar from './components/NavBar.vue';
  export default {
    name: 'app',
    data() {
      return {}
    },
    methods: {
      hasSubMenu(navItem) {
        if (navItem.subMenu != undefined && navItem.subMenu != null) {
          if (navItem.subMenu.length > 0) {
            return true;
          }
        }
        return false;
      },
      deleteTime(timeEntry) {
        this.totalTime -= parseFloat(timeEntry.totalTime);
      },
      timeUpdate(timeEntry) {
        this.totalTime += parseFloat(timeEntry.totalTime);
      },
      active(navId, event) {
        this.activeNav = navId;
      },
      inActive() {
        this.activeNav = "";
      },
      isActive(navId) {
        return this.activeNav == navId;
      },
      getPage(navId) {
        this.currentPage = {
          id: "page1",
          nav: {
            id: 'menu2',
            path: '/time-entries',
            name: '菜单2'
          },
          subtitles: [{
            id: "1",
            name: "subtitle1"
          }, {
            id: "2",
            name: "subtitle2"
          }]
        };
      }
    },
    events: {
      timeUpdate(timeEntry) {
        this.totalTime += parseFloat(timeEntry.totalTime);
      },
      deleteTime(timeEntry) {

        this.totalTime -= parseFloat(timeEntry.totalTime);
      }
    },
    components: {
      NavBar
    }
  }
</script>

<style>

</style>
